<template>
  <div>
    <el-tag v-for="tag in tags" :type="tag.type" :key="tag.id">{{ tag.name }}</el-tag>
  </div>
</template>

<script>

export default {
  name: "TagGroup",
  props: {
    data: {
      type: Array,
      default: function() {
        return [];
      }
    }
  },
  data() {
    return {
      tagTypes: ['', 'success', 'info', 'warning', 'danger']
    }
  },
  computed: {
    tags() {
      let typeNum = this.tagTypes.length,
        tagTypes = this.tagTypes
      return this.data.map(function(item) {
        return { name: item.name, type: tagTypes[item.id % typeNum] }
      })
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
